//function to handle login-form validation
function loginValidate(loginForm){

var validationVerified=true;
var errorMessage="";
var okayMessage="click OK to continue";

if (loginForm.login.value=="")
{
errorMessage+="Username not filled!\n";
validationVerified=false;
}
if(loginForm.password.value=="")
{
errorMessage+="Password not filled!\n";
validationVerified=false;
}
if(!validationVerified)
{
alert(errorMessage);
}
if(validationVerified)
{
alert(okayMessage);
}
return validationVerified;
}

function updateValidate(updateForm) {
    var validationVerified=true;
var errorMessage="";
var okayMessage="click OK to change your password";

if (updateForm.opassword.value=="")
{
errorMessage+="Please provide your current password.\n";
validationVerified=false;
}
if (updateForm.npassword.value=="")
{
errorMessage+="Please provide a new password.\n";
validationVerified=false;
}
if(updateForm.cpassword.value=="")
{
errorMessage+="Please confirm your new password.\n";
validationVerified=false;
}
if(updateForm.cpassword.value!=updateForm.npassword.value)
{
errorMessage+="Confirm password and new password do not match!\n";
validationVerified=false;
}
if(!validationVerified)
{
alert(errorMessage);
}
if(validationVerified)
{
alert(okayMessage);
}
return validationVerified;
}

//validate staffForm
function staffValidate(staffForm) {
    var validationVerified=true;
var errorMessage="";
var okayMessage="click OK to add staff information";

if (staffForm.fName.value=="")
{
errorMessage+="Please provide the staff first name.\n";
validationVerified=false;
}
if (staffForm.lName.value=="")
{
errorMessage+="Please provide the staff last name.\n";
validationVerified=false;
}
if (staffForm.sAddress.value=="")
{
errorMessage+="Please provide the staff street address.\n";
validationVerified=false;
}
if(staffForm.mobile.value=="")
{
errorMessage+="Please provide the staff mobile/telephone number.\n";
validationVerified=false;
}
if(!validationVerified)
{
alert(errorMessage);
}
if(validationVerified)
{
alert(okayMessage);
}
return validationVerified;
}

//function to handle specialsForm validation
function specialsValidate(specialsForm){

var validationVerified=true;
var errorMessage="";
var okayMessage="click OK to update promotion";

if (specialsForm.price.value=="")
{
errorMessage+="price not filled!\n";
validationVerified=false;
}
if(specialsForm.startDate.value=="")
{
errorMessage+="start date not filled!\n";
validationVerified=false;
}
if(specialsForm.endDate.value=="")
{
errorMessage+="end date not filled!\n";
validationVerified=false;
}
if(!validationVerified)
{
alert(errorMessage);
}
if(validationVerified)
{
alert(okayMessage);
}
return validationVerified;
}

//function to handle ordersAllocation form validation
function ordersAllocationValidate(allocationForm){

var validationVerified=true;
var errorMessage="";
var okayMessage="click OK to allocate staff";

if (allocationForm.orderid.value=="")
{
errorMessage+="Order ID not filled!\n";
validationVerified=false;
}
if(allocationForm.staffid.value=="")
{
errorMessage+="Staff ID not filled!\n";
validationVerified=false;
}
if(!validationVerified)
{
alert(errorMessage);
}
if(validationVerified)
{
alert(okayMessage);
}
return validationVerified;
}

//function to handle reservationsAllocation form validation
function reservationsAllocationValidate(allocationForm){

var validationVerified=true;
var errorMessage="";
var okayMessage="click OK to allocate staff";

if (allocationForm.reservationid.value=="")
{
errorMessage+="Reservation ID not filled!\n";
validationVerified=false;
}
if(allocationForm.staffid.value=="")
{
errorMessage+="Staff ID not filled!\n";
validationVerified=false;
}
if(!validationVerified)
{
alert(errorMessage);
}
if(validationVerified)
{
alert(okayMessage);
}
return validationVerified;
}

//function to handle message validation
function messageValidate(messageForm){

var validationVerified=true;
var errorMessage="";
var okayMessage="click OK to send the message to all customers";

if (messageForm.txtmessage.value=="")
{
errorMessage+="message not filled!\n";
validationVerified=false;
}
if(!validationVerified)
{
alert(errorMessage);
}
if(validationVerified)
{
alert(okayMessage);
}
return validationVerified;
}